﻿#include "HeartInfo.h"
#include "../util/JsonUtil.h"
#include "../util/Md5Util.h"

HeartInfo::HeartInfo()
{
}

HeartInfo::~HeartInfo()
{
}

std::string HeartInfo::GetId()
{
	return m_id;
}

void HeartInfo::SetId(std::string v)
{
	m_id = v;
}

std::string HeartInfo::GetIp()
{
	return m_ip;
}

void HeartInfo::SetIp(std::string v)
{
	m_ip = v;
}

int HeartInfo::GetPort()
{
	return m_port;
}

void HeartInfo::SetPort(int v)
{
	m_port = v;
}

std::string HeartInfo::ToJson()
{
	std::stringstream stream;
	try
	{
		boost::property_tree::ptree pt;
		pt.put("id", m_id);
		pt.put("ip", m_ip);
		pt.put("port", m_port);
		pt.put("cmd", "heart");
		boost::property_tree::write_json(stream, pt);
	}
	catch (boost::property_tree::ptree_error pt)
	{
		pt.what();
		return "";
	}
	return stream.str();
}